package com.wlc.socket.demo01_v3;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author 王立朝 wanglichao@champion-credit.com
 * @description 发送消息的线程
 * @date 2021-07-15 14:28
 */
public class ReciveThread extends Thread {

    private Socket socket;

    public ReciveThread(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            InputStream os = socket.getInputStream();
            DataInputStream dos = new DataInputStream(os);
            while (true) {
                String s = dos.readUTF();

                System.out.println("接收完毕～，接收到的内容为：" + s);

            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
